objective of this section: exec replaces the process image of the EXEC Association function Group (EXECL, EXECLP, Execle, EXECV, EXECVP) One, exec replaces the process image on the process creation Unix takes a unique approach, It separates the process creation from the loading of a new process image. The advantage is that there is more room to manage the two operations. When we create a process, we usually replace the child process with a new process
Run execl, execle, execlp, execv, execve, and execvp functions in the process, execleexecvpAbstract:This article describes how to run new code in the process and the basic usage of exec functions.
Run new code in the processAfter using the fork function to create a sub-process, if you want to run a new program in the current sub-process, you can call the exec function to execute another program. when a process calls the exec function, the user space r
5 process primitives: execl (), execlp (), execle (), execv (), execvp (), execvp (), execve (), execlpexecleZookeeper
Header files dependent on the 1.exe c family
# Include
Extern char ** environ;
2 function declaration
// The first parameter is the absolute location of the executable program.
// The second parameter: The parameter required when the executable program runs. It is a variable parameter, separated by commas (,).
// When the parameter e
can call the fork function to create a new process, and then call any exec function to regenerate the child process.
(3) exec function family syntax
In fact, in Linux, there are no exec functions, but six Function Families starting with exec. The following table lists the syntax of the six member functions of the exec function family.
Header files
# Include
Function Description
Execution File
Function prototype
Int execl (const char * path, const char * Arg
The EXEC function under Linux is not a single function, but a function group, respectively:
int execl (const char *path, const char *arg, ...);
int EXECLP (const char *file, const char *arg, ...);
int execle (const char *path, const char *arg, ..., char * const envp[]);
int execv (const char *path, char *const argv[]);
int EXECVP (const char *file, char *const argv[]);
int Execve (const char *path, char *const argv[], char *const envp[]);
You ca
When I read some old documents and occasionally communicated with scrippoe, I had the idea of writing this article. He told me a technology based on buffer overflow, including general stack buffer overflow and no nops is required under any circumstances. In other words, we put our buffer in the stack (preferably in the environment) and precisely know the address it locates. This article is based on the method he told me very early.When we call vulnerable programs in our exploit, we have several
Linux schedules the operation of a process by maintaining five states. These five states are: Run, interruptible, non-interruptible, zombie, stop.PID to identify different processes, each of the processes in Linux has a unique process number.A PCB block is a process resource1.fork functionInclude pid_t fork (void)return value 0: Child process child process ID (greater than 0)-1: ErrorThe child process that is obtained by using the fork function is a replica of the parent process. Using the fork
Execl (Execution file)
Related functions
Fork, execle, execlp, execv, execve, execvp
Header file
# Include
Define functions
Int execl (const char * path, const char * Arg ,....);
Function Description
Execl () is used to execute the file path represented by the path string parameter. The following parameter indicates that the previous argv (0), argv [1]…, The last parameter must end with a null pointer.
read this series of articles from the very beginning, but there is still a big question: Since all new processes are generated by fork, in addition, the sub-processes generated by fork are almost identical with the parent process. Doesn't that mean that all the processes in the system should be identical? Moreover, in our common sense, when we execute a program, the content of the new process should be the content of the program. Did we get it wrong? Obviously not. To solve these questions, we
actually a callback function, passed the function pointerEXEC-associated function familyQ Contains header files The Q function uses the EXEC function to replace the current process with a new one. exec name is a complete series of multiple correlation functions, header file Q Prototypes/*#include extern char **environ;int execl (const char *path, const char *arg, ...);int EXECLP (const char *file, const char *arg, ...); PATHint execle (const char *pa
representation.The null effect here is the same as the null function in the argv array. The letter P refers to the directory where the environment variable path is located to find the executable file to execute. The 2 functions EXECLP and EXECVP, which end in P, seem to differ very little from those of Execl and execv, and they differ from the first parameter name: 4 functions except EXECLP and EXECVP are required,Their 1th parameter path must be a complete path, such as "/bin/ls", while the 1t
1. Exec replacement process image
On Process Creation, Unix adopts a unique method, which separates Process Creation from loading a new process image. The advantage is that there is more room to manage the two operations. After we create a process, we usually replace the child process with a new process image. This can be done using exec functions. Of course, the exec series functions can also replace the current process.
2. Exec Associated Function Group
Include header file The exec function ca
exec function family.
Let yourself be reborn;
· If a process wants to execute another program, it can call the fork function to create a new process, and then
Call any exec, which looks like a new process is generated by executing the application. (In this case
Very common) (2) exec function family syntax
In fact, there is no exec () function in Linux, but there are 6 Function Families starting with exec.
There are nuances in the method, which will be explained in detail below. Header file requ
provides two parameter passing Methods: one is to list the parameters one by one, and the other is to construct an array of pointers for all parameters. It is distinguished by a 5th-bit Letter of the function name. the letter "L" (list) represents the way parameters are listed one by one. Its syntax is const char * ARG; the letter "V" (vector) indicates that all parameters are passed in an integral constructor array. Its syntax is char * const argv []. The parameters here are actually all the C
is to construct an array of pointers for all parameters. It is distinguished by a 5th-bit Letter of the function name. the letter "L" (list) represents the way parameters are listed one by one. Its syntax is const char * ARG; the letter "V" (vector) indicates that all parameters are passed in an integral constructor array. Its syntax is char * const argv []. The parameters here are actually all the Command Option strings (including the executable program command itself) required by the user whe
. For example, you can check the credentials of a user before starting another program that has a restricted usage policy. The EXEC function is more efficient than the system function because the original program is no longer running after the new program starts.#include Char **environ;int execl (const char *path, const char *arg0, ..., (char *) 0);int EXECLP (const char *file, const char *arg0, ..., (char *) 0);int execle (const char *path, const cha
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.